<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    // repeat 重复输出字符串
    var str = "*";
    var res = str.repeat(4);
    console.log(res);   // ****


    // startsWith 判断字符串是否以某个字符开头
    var str1 = "abcdef";
    console.log(str.startsWith("ab"));  // false


    // endsWith 判断字符串是否以某字符结尾
    var str2 = "abcdef";
    console.log(str2.endsWith("f"));    // true


    // padStart 补全前面字符串
    var str3 = "abc";
    var res1 = str3.padStart(5,"*");
    console.log(res1);  // **abc


    // padEnd 补全后面字符串
    var str4 = "abc"
    var res2 = str4.padEnd(5,"*");
    console.log(res2);  // abc**


    // includes 判断字符串是否包含某个字符
    var str5 = "abcdef";
    console.log(str5.includes("cdf"));  // false


    // 过滤敏感词
    var str5 = "fsXhsxxuhfbXaxxhweuifwiuxxdifhi";
    // console.log(str5.replace(/\x|\X/g,"*"));
    var reg = /x+|X+/g;
    var res = srt5.replace(reg,function(){
        console.log(arg);
        return "*".repeat(arg.length);
    });
    console.log(res);


</script>